const filterHideMenu = (routes) => {
    let list = [];

    for (var i = 0; i < routes.length; i++) {
        // console.log("过滤路由：\n", routes[i]);
        if ((routes[i].menuType === "1" && routes[i].children.length <= 0)) {
            // 隐藏visible为false的菜单 或者 隐藏 menuType为1（类型为目录）且children.length<=0（目录里没有菜单）的节点
        } else {
            list.push({
                ...routes[i],
                children: (routes[i].children && routes[i].children.length) ? filterHideMenu(routes[i].children) : undefined
            })
        }

    }


    return list;
}

const filterVisibleMenu = (routes) => {
    let list = [];

    for (var i = 0; i < routes.length; i++) {
        // console.log("过滤路由：\n", routes[i]);
        if (routes[i].visible === "0" || (routes[i].menuType === "1" && routes[i].children.length <= 0)) {
            // 隐藏visible为false的菜单 或者 隐藏 menuType为1（类型为目录）且children.length<=0（目录里没有菜单）的节点
        } else {
            list.push({
                ...routes[i],
                children: (routes[i].children && routes[i].children.length) ? filterHideMenu(routes[i].children) : undefined
            })
        }

    }


    return list;
}

export default filterHideMenu;
export { filterVisibleMenu }